package com.mmall.concurrency.thread.one;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * 功能描述：
 *
 * @author 吴明泽
 * @version 1.0
 * @date 2022-10-11 11:19:07
 */
public class ShowDemo {

    int i = 0;

    public void incy() {
        i++;
    }

    public static void main(String[] args) throws InterruptedException {


        final ReentrantLock lock = new ReentrantLock();


        ShowDemo showDemo = new ShowDemo();
        final Thread[] threads = new Thread[2];
        for (int i = 0; i < 2; i++) {
            threads[i] = new Thread(() -> {
                for (int j = 0; j < 10000; j++) {
                    showDemo.incy();
                }
            });
            threads[i].start();
        }

        threads[0].join();
        threads[1].join();
        System.out.println(showDemo.i);

    }


}
